package dawi.fcs.servicio.servicio.impl;

import java.util.HashMap;
import java.util.List;

import dawi.fcs.dominio.Cliente;
import dawi.fcs.dominio.Ubigeo;
import dawi.fcs.servicio.dao.ClienteDao;
import dawi.fcs.servicio.factory.DAOFactory;
import dawi.fcs.servicio.generico.GenericoServicioImpl;
import dawi.fcs.servicio.servicio.ClienteServicio;

public class ClienteServicioImpl extends GenericoServicioImpl implements
		ClienteServicio {
	private ClienteDao dao;

	public ClienteServicioImpl() {
		dao = DAOFactory.getFactorty(DAOFactory.MYSQL).getClienteDao();
		this.setGenericoDao(dao);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public List<Ubigeo> listarDepartamento() {
		List list = dao.listarPorQuery("cliente.listarUbigeoDepa");
		return list;
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public List<Ubigeo> listarProvincia(String depa) {
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("depa", depa);
		List list = dao.listarPorQuery("cliente.listarUbigeoProvi", map);
		return list;
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public List<Ubigeo> listarDistrito(String depa, String provi) {
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("depa", depa);
		map.put("provi", provi);
		List list = dao.listarPorQuery("cliente.ListarUbigeoDist", map);
		return list;
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public List<Cliente> listarPaginacion(HashMap<String, Object> map) {
		List list = dao.listarPorQuery("cliente.listarPaginacion", map);
		return list;
	}

	@Override
	public Integer validarNroDocumento(String nrodoc) {
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("nroDocumento", nrodoc);
		return dao.contar("cliente.validaNroDoc", map);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public List<Cliente> listarSelectorParte(String expediente) {
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("nro_expediente", expediente);
		List list = dao.listarPorQuery("cliente.listarSelectorParte", map);
		return list;
	}

	@Override
	public Integer obtenerUltimoRegistrado() {
		return dao.contar("cliente.obtenerUltimoRegi",
				new HashMap<String, Object>());
	}

	@Override
	public Integer contarPorCelular(Integer cel) {
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("cel", cel);
		return dao.contar("cliente.contarPorCelular", map);
	}
}
